//
//  NSDictionary+Add.m
//  MyFrameWork
//
//  Created by eason on 16/4/25.
//  Copyright © 2016年 普惠. All rights reserved.
//

#import "NSDictionary+Add.h"

@implementation NSDictionary (Add)


- (int)intForKey:(NSString *)key
{
    if (![self objectForKey:key]) {
        return 0;
    }
    
    id tmp = [self objectForKey:key];
    
    if ([tmp isEqual:[NSNull null]]) {
        return 0;
    }
    
    return [tmp intValue];
}

- (long)longForKey:(NSString *)key
{
    if (![self objectForKey:key]) {
        return 0L;
    }
    
    id tmp = [self objectForKey:key];
    
    if ([tmp isEqual:[NSNull null]]) {
        return 0L;
    }
    
    return [tmp longValue];
}

- (double)doubleForKey:(NSString *)key
{
    id tmp = [self objectForKey:key];
    if (tmp != [NSNull null]) {
        return [tmp doubleValue];
    }
    return 0.00;
}

- (BOOL)booleanForKey:(NSString *)key
{
    id tmp = [self objectForKey:key];
    if (tmp != [NSNull null]) {
        return [tmp boolValue];
    }
    return NO;
}

- (NSArray *)arrayForKey:(NSString *)key
{
    id tmp = [self objectForKey:key];
    if (tmp != [NSNull null]) {
        return tmp;
    }
    return [NSArray array];
}

@end
